WORK_DIR=~/OpenHarmony
TEST_CASE=$1
TEST_CASE_BASENAME=${TEST_CASE%.*}

FRONT_TOOL_PATH=$WORK_DIR/out/rk3568/clang_x64/arkcompiler/ets_frontend

# release
# SET_ENV_CMD="export LD_LIBRARY_PATH=$WORK_DIR/out/rk3568/clang_x64/arkcompiler/ets_runtime/:$WORK_DIR/prebuilts/clang/ohos/linux-x86_64/llvm/lib:$WORK_DIR/out/rk3568/clang_x64/thirdparty/zlib/:$WORK_DIR/out/rk3568/clang_x64/thirdparty/icu/"
# RUNTIME_TOOL_PATH=$WORK_DIR/out/rk3568/clang_x64/arkcompiler/ets_runtime

# debug
SET_ENV_CMD="export LD_LIBRARY_PATH=$WORK_DIR/out/rk3568/clang_x64/lib.unstripped/clang_x64/arkcompiler/ets_runtime/:$WORK_DIR/prebuilts/clang/ohos/linux-x86_64/llvm/lib:$WORK_DIR/out/rk3568/clang_x64/thirdparty/zlib/:$WORK_DIR/out/rk3568/clang_x64/thirdparty/icu/"
RUNTIME_TOOL_PATH=$WORK_DIR/out/rk3568/clang_x64/exe.unstripped/clang_x64/arkcompiler/ets_runtime

echo
echo $SET_ENV_CMD
echo
$SET_ENV_CMD

GEN_ABC_CMD="$FRONT_TOOL_PATH/es2abc --merge-abc --output $TEST_CASE_BASENAME.abc $TEST_CASE"
# AOT_CMD="$RUNTIME_TOOL_PATH/ark_aot_compiler --log-level=info --compiler-log=all012  --aot-file=$TEST_CASE_BASENAME  $TEST_CASE_BASENAME.abc"
# AOT_CMD="$RUNTIME_TOOL_PATH/ark_aot_compiler --compiler-target-triple=aarch64-unknown-linux-gnu --log-level=info --compiler-log=all012  --aot-file=$TEST_CASE_BASENAME  $TEST_CASE_BASENAME.abc"
AOT_CMD="$RUNTIME_TOOL_PATH/ark_aot_compiler --log-level=info --compiler-log=all012 --compiler-enable-litecg=true --aot-file=$TEST_CASE_BASENAME  $TEST_CASE_BASENAME.abc"
RUN_VM_CMD="$RUNTIME_TOOL_PATH/ark_js_vm --icu-data-path=$WORK_DIR/third_party/icu/ohos_icu4j/data/ --aot-file=$TEST_CASE_BASENAME --entry-point=$TEST_CASE_BASENAME $TEST_CASE_BASENAME.abc"

echo $GEN_ABC_CMD
echo
$GEN_ABC_CMD
echo $AOT_CMD
echo
$AOT_CMD >aot_log.txt
echo $RUN_VM_CMD
echo
$RUN_VM_CMD
